#include "Pipe.h"
//#include "Global.h"
#include "Resource.h"

Pipe::Pipe(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, LPD3DXSPRITE SpriteHandler, float x, float y, int IDObjType, int Object_State) : Object(x, y)//, IDObjType, Object_State)
{
	this->setIDObjType(IDObjType);
	switch (this->getIDObjType())
	{
	case  24:	//ong trung binh
	case 241:	//ong trung binh co the chui xuong
	case 242:	//ong trung binh chui len
		p_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\pipe_mid.png"), 0, 0);
		break;
	case  52:	//ong thap
	case  521:	//ong thap co the chui xuong
	case  522:	//ong thap chui len
		p_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\pipe_min.png"), 0, 0);
		break;
	case  53:	//ong cao
	case  531:	//ong cao co the chui xuong
	case  532:	//ong cao chui len
		p_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\pipe_max.png"), 0, 0);
		break;
	case  29:	//ong nam ngang
		p_sprite = new Sprite(SpriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\pipe_ngang.png"), 0, 0);
		break;
	}

	width = p_sprite->getTexture()->getWidth();
	height = p_sprite->getTexture()->getHeight();

	
	this->obj_state = Object_State;	//mac dinh la 1	
	direction = 0;
	if (this->obj_state == 2)		//cong 24 co the chuoi xuong
	{

	} 
	else if (this->obj_state == 3)	//cong 24 co the chui len
	{
	}

	

	veloc_x = 0;
	veloc_y = 0;
	accel_x = 0;
	accel_y = 0;
}

Pipe::~Pipe()
{
	if (p_sprite)
	{
		delete p_sprite;
	}
}

 

void Pipe::render(int cameraX, int cameraY)
{
	Object::render(cameraX, cameraY);
}

OBJECT_TYPE Pipe::getObjectType()
{
	return OBJECT_LAND;
}

 

void Pipe::update(list<Object*>* obj_list, DxInput* input, float TPF)
{
	Object::update(obj_list, input, TPF);
}